/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * <p>Project: jse2302 - Client
 * <p>Powered by webrx On 2023-06-30 14:07:45
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Client {
    public static void main(String[] args) {
        try (var s = new Socket("192.168.11.44", 1212)) {

            while (true) {
                //发送s.getOutputStream();
                //发送s.getOutputStream();
                PrintWriter out = new PrintWriter(s.getOutputStream());
                Scanner sc = new Scanner(System.in);
                System.out.println("请输入信息：");
                String msg = sc.nextLine() + "\r\n";
                out.write(msg);
                out.flush();
                //接收s.getInputStream();
                BufferedReader read = new BufferedReader(new InputStreamReader(s.getInputStream()));
                System.out.println(read.readLine());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
